﻿/*************************************************************************
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CatchUpTv.Utilities;
using System.Diagnostics;

namespace CatchUpTv.Tv
{
    /// <summary>
    /// A TV show.
    /// </summary>
    [DebuggerDisplay("Show: '{Id}'")]
    public class Show
    {
        /// <summary>
        /// The Id for the show.
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// An associated object.
        /// </summary>
        public object Tag { get; set; }

        /// <summary>
        /// The show name.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// The show description.
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// The image URL for the show. 
        /// </summary>
        public string ImageUrl { get; set; }

        /// <summary>
        /// The list of episodes under this show.
        /// </summary>
        public Lazy<IEnumerable<Episode>> Episodes { get; set; }

        /// <summary>
        /// Converts this instance to a string.
        /// </summary>
        /// <returns>The string.</returns>
        public override string ToString()
        {
            return new ToStringBuilder<Show>(this)
                .Append(s => s.Id)
                .Append(s => s.Name)
                .ToString();
        }

        public override bool Equals(Object obj)
        {
            Show other = obj as Show;

            if (other == null)
            {
                return false;
            }

            return new EqualsBuilder()
                .Append(Id, other.Id)
                .IsEquals();
        }

        public override int GetHashCode()
        {
            return new HashCodeBuilder(73, 13)
                .Append(Id)
                .ToHashCode();
        }
    }
}
